﻿using AspNetCoreAbp.Domains.Models;
using Microsoft.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.Modeling;

namespace AspNetCoreAbp.EntityFrameworkCores;

public class AppDbContext : AbpDbContext<AppDbContext>
{
    public AppDbContext(DbContextOptions<AppDbContext> options) : base(options)
    {
    }

    public DbSet<Order> Orders { get; set; }

    protected override void OnModelCreating(ModelBuilder builder)
    {
        base.OnModelCreating(builder);

        builder.Entity<Order>(o =>
        {
            o.ToTable("Orders");
            o.ConfigureByConvention(); //auto configure for the base class props
            o.Property(x => x.Name).IsRequired().HasMaxLength(128);
        });
    }
}